
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-2.1.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>

    <script>
        $(function () {




            /*//给删除按钮添加点击事件
            $("#deleteSelect").click(function (){
                var selectFlag = false;
                if(confirm("确定要删除选中的评论吗?")){
                    $("#commentsform").attr("action","${pageContext.request.contextPath}/myself/deleteAll");
                    var cbs=document.getElementsByName("selected");
                    for (var i=0;i<cbs.length;i++){
                        if (cbs[i].checked){
                            selectFlag = true;
                            break;
                        }
                    }

                }
                if(selectFlag){
                    $("#commentsform").submit();
                }
            });

            //给取消按钮添加点击事件
            $("#deleteSelectCollect").click(function (){
                var selectFlag = false;
                if(confirm("确定要取消选中的收藏吗?")){
                    $("#collectform").attr("action","${pageContext.request.contextPath}/myself/cancelAll");
                    var cbs=document.getElementsByName("collectselected");
                    for (var i=0;i<cbs.length;i++){
                        if (cbs[i].checked){
                            selectFlag = true;
                            break;
                        }
                    }

                }
                if(selectFlag){
                    $("#collectform").submit();
                }
            });

            $("#controlAll").click(function () {
                var flag = $(this).prop("checked");
                $(".selected").prop("checked",flag);
            });

            $("#collectControlAll").click(function () {
                var flag = $(this).prop("checked");
                $(".collectselected").prop("checked",flag);
            });*/

            $("#attentionOther").click(function () {
               $.ajax({
                   url:"${pageContext.request.contextPath}/show/attentionOther",
                   type:"post",
                   data:$("#myselfmsg").serialize(),
                   dataType:"json",
                   success:function (data) {
                       if (data.flag){
                           alert(data.errorMsg);

                       }else {
                           location.href="${pageContext.request.contextPath}/show/getOtherMsg";
                       }
                   }
               })
            });

        });
    </script>

</head>
<body>
<c:import url="component/header.jsp"></c:import>

<table id="myselfmsg" class="myselfmsg" align="center">
    <tr>
        <td><h3>${sessionScope.otherUser.username}</h3></td>
        <td><button href="#" id="attentionOther">关注</button></td>
    </tr>
    <tr>
        <td>ta关注的:</td>
        <td>${sessionScope.otherAttentionNum}</td>
    </tr>
<%-- <tr>
        <td>邮箱:</td>
        <td>${sessionScope.user.email}</td>
    </tr>
    <tr>
        <td>姓名:</td>
        <td>name</td>
    </tr>
    <tr>
        <td>禁言状态:</td>
        <td>禁言</td>
    </tr>--%>
</table>
<%--<div class="row">
    <div class="col-md-4"></div>
    <div class="col-md-4"><span style="font-size:100px ">username</span></div>
    <div class="col-md-4"><button href="#" type="submit">关注</button></div>
</div>--%>
<%--评论--%>
<div class="container">
    <h3 style="text-align: left">ta的评论</h3>
    <div style="float: left">
        <form class="form-inline" action="${pageContext.request.contextPath}/show/selectOtherComments" id="selectform" method="post">
            <div class="form-group">
                <label for="selectname">动漫名</label>
                <input type="text" class="form-control" id="selectname" name="selectname" placeholder="查询所有" value="查询所有" >
            </div>
            <button type="submit" class="selectbutton">查询</button>
        </form>
    </div>
<%--    <div style="float: right">
        <tr>
            <td colspan="8" align="center"><a class="btn btn-primary" href="#" id="deleteSelect">删除选中</a></td>
        </tr>
    </div>--%>

    <%--    删除选中：添加form表单标签--%>
    <form action="#" method="post" id="commentsform">
        <table border="1" class="table table-bordered table-hover">
            <tr class="success"  style="background: red">
                <%--<th>
                    <input type="checkbox"  name="controlAll" id="controlAll">
                </th>--%>
                <th>封面</th>
                <th>动漫名</th>
                <th>评论内容</th>
                <th>创建时间</th>
                <th>点赞数</th>
                <%--<th>操作</th>--%>
            </tr>
            <c:forEach items="${sessionScope.otherComments}" var="list" varStatus="s">
                <tr>
                   <%-- <td>
                        <input type="checkbox" class="selected" name="selected" id="selected" value="${list.commentsDO.com_id}">
                    </td>--%>
                    <td><img src="${pageContext.request.contextPath}/${list.animationSimpleDO.cover_img}" alt="图片正在加载..." height="50"></td>
                    <td>${list.animationSimpleDO.aname}</td>
                    <td>${list.commentsDO.context}</td>
                    <td>${list.commentsDO.create_time}</td>
                    <td>${list.commentsDO.like_num}</td>
                    <%--<td>&lt;%&ndash;<a class="btn btn-default btn-sm" href="#">修改评论</a>&nbsp;&ndash;%&gt;
                        <a class="btn btn-default btn-sm" id="deleteComments" href="#?cid=${list.commentsDO.com_id}">点赞评论</a></td>--%>
                </tr>

            </c:forEach>

        </table>
    </form>

</div>
<%--收藏collect--%>

<div class="container">
    <h3 style="text-align: left">ta的收藏</h3>
    <div style="float: left">
        <form class="form-inline" action="${pageContext.request.contextPath}/show/selectOtherCollect" id="selectCollectform" method="post">
            <div class="form-group">
                <label for="selectname">动漫名</label>
                <input type="text" class="form-control" id="selectCollectname" name="selectCollectname" placeholder="查询所有" value="查询所有" >
            </div>
            <button type="submit" class="selectbutton">查询</button>
        </form>
    </div>
<%--    <div style="float: right">
        <tr>
            <td colspan="8" align="center"><a class="btn btn-primary" href="#" id="deleteSelectCollect">取消收藏</a></td>
        </tr>
    </div>--%>

    <%--删除选中：添加form表单标签--%>
    <form action="#" method="post" id="collectform">
        <table border="1" class="table table-bordered table-hover">
            <tr class="success">
                <%--<th>
                    <input type="checkbox"  name="collectControlAll" id="collectControlAll">
                </th>--%>
                <th>封面</th>
                <th>动漫名</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${sessionScope.otherCollect}" var="clist" varStatus="s">
                <tr>
                    <%--<td>
                        <input class="collectselected" type="checkbox" name="collectselected" id="collectselected" value="${clist.animationSimple.aid}">
                    </td>--%>
                    <p hidden>${clist.animationSimple.aid}</p>
                    <td><img src="${pageContext.request.contextPath}/${clist.animationSimple.cover_img}" alt="图片正在加载..." height="50"></td>
                    <td>${clist.animationSimple.aname}</td>
                    <td>
                        <a class="btn btn-default btn-sm" class="addCollect">收藏</a>
                    </td>
                </tr>
            </c:forEach>
            <script>
                $(document).ready(function () {
                    $(".addCollect").click(function () {
                        let aid = $(this).parent().parent().children("p").html();
                        $.ajax({
                            url:"${pageContext.request.contextPath}/animation/isCollect",
                            data:{"aid":aid},
                            type:"post",
                            dataType:"json",
                            success:function (data) {
                                if (data.flag) {
                                    $.ajax({
                                        url:"${pageContext.request.contextPath}/animation/collectAdd",
                                        data:{"aid":aid},
                                        type:"post",
                                        dataType:"json",
                                        success:function (data) {
                                            if (data.flag) {
                                                alert("收藏成功");
                                            } else {
                                                alert("收藏失败！");
                                            }
                                        }
                                    })
                                } else {
                                    alert("你已经关注过了！");
                                }
                            }
                        })
                    })
                })
            </script>
        </table>
    </form>
</div>
</body>
</html>
